#pragma once
#include <boost/thread.hpp>
#include "NetConnect.h"
#include <boost/asio.hpp>
#include <boost/atomic.hpp>
using namespace boost::asio;
class CNetSevice
{
public:
	CNetSevice(const ZMString& address, const ZMString& port);

	/// Handle a request to stop the server.
	void Stop();
	
	void Start();
protected:
	/// Handle completion of an asynchronous accept operation.
	void handle_accept(const boost::system::error_code& e);


	void StartMain();
private:
	boost::asio::io_service m_io_service;

	/// Acceptor used to listen for incoming connections.
	boost::asio::ip::tcp::acceptor m_acceptor;

	PNetConnect m_pNewConnect;

	boost::atomic<bool> m_isServerRun;

};

